import request from '@/utils/request'

export default {
  getDepartmentList(searchModel) {
    return request({
      url: '/department/list',
      method: 'get',
      params: {
        page: searchModel.page,
        pageSize: searchModel.pageSize,
        name: searchModel.name,
        manager: searchModel.manager

      }
    })
  },
  addDepartment(department) {
    return request({
      url: '/department',
      method: 'post',
      data: department
    })
  },
  getDepartmentById(id) {
    return request({
      // url: '/user/' + id,
      url: `/department/${id}`,
      method: 'get'
    })
  },
  updateDepartment(department) {
    return request({
      url: '/department',
      method: 'put',
      data: department
    })
  },
  saveDepartment(department) {
    if (department.id == null && department.id === undefined) {
      return this.addDepartment(department)
    }
    return this.updateDepartment(department)
  },
  deleteDepartment(id) {
    return request({
      // url: '/user/' + id,
      url: `/department/${id}`,
      method: 'delete'
    })
  }
}
